import request from '@/utils/request'

// --------------------------------------------------------------------------start数据字典

// 通用模块 / 获取数据字典 -- 后台
export function findDictionaryData(query) {
  return request({
    url: '/admin/sys/dictionaryData/public/find',
    method: 'get',
    params: query
  })
}

// 通用模块 / 获取数据字典 -- 账户
export function dictionaryDataFind(query) {
  return request({
    url: '/account/common/dictionaryData/find',
    method: 'get',
    params: query
  })
}

// 获取数据字典文件夹
export function fetchDictionaryList() {
  return request({
    url: '/admin/sys/dictionaryFolder/list',
    method: 'get'
  })
}

// 新增字典文件夹
export function saveDictionary(query) {
  return request({
    url: '/admin/sys/dictionaryFolder/save',
    method: 'POST',
    data: query
  })
}

// 更新字典文件夹
export function updateDictionary(query) {
  return request({
    url: '/admin/sys/dictionaryFolder/update/' + query.id,
    method: 'POST',
    data: query
  })
}

// 新增字典数据
export function saveDictionaryData(query) {
  return request({
    url: '/admin/sys/dictionaryData/save',
    method: 'POST',
    data: query
  })
}

// 更新数据字典name code
export function updateDictionaryData(query) {
  return request({
    url: '/admin/dictionaryData/update/' + query.id,
    method: 'POST',
    data: query
  })
}

// 根据第一层级字典获取字典数据
export function getDictionaryData(query) {
  return request({
    url: '/admin/sys/dictionaryData/list',
    method: 'GET',
    params: query
  })
}

// 删除文件夹
export function deleteDictionaryFolder(query) {
  return request({
    url: '/admin/sys/dictionaryFolder/delete',
    method: 'POST',
    data: query
  })
}

// 删除数据类型
export function deleteDictionaryData(query) {
  return request({
    url: '/admin/sys/dictionaryData/public/delete',
    method: 'POST',
    data: query
  })
}

// 修改字典类型的文件夹（移动文件）
export function moveDictionaryFolder(query) {
  return request({
    url: '/admin/sys/dictionaryData/updateFolder/' + query.id,
    method: 'POST',
    data: query
  })
}

// ------------------------------------------------------------------------------------end数据字典

// ------------------------------------------------------------------------------------start 账户操作

// 获取当前用户相关信息
export function memberInfo(data) {
  return request({
    url: '/member/info',
    method: 'get',
    params: data
  })
}

// 修改当前用户信息
export function updateMember(data) {
  return request({
    url: '/admin/member/update',
    method: 'post',
    data: data
  })
}

// 修改当前用户密码
export function updatePassword(data) {
  return request({
    url: '/admin/member/updatePassword',
    method: 'post',
    data: data
  })
}
// ------------------------------------------------------------------------------------end 账户操作

// 通用删除
export function generalRemove(data, location) {
  return request({
    url: '/admin/' + location + '/delete/',
    method: 'post',
    data: data
  })
}
